﻿//using System.Collections;
//using System.Collections.Generic;
//using UnityEngine;
//using UnityEngine.UI;
//using QQSDK;

//public class IAPTestScene : MonoBehaviour {

//    public static IAPTestScene instance;

//    public Text GlodNumber;
//    private int GlodCount;


//    public Text removeAdsUser;
//    private bool isRemoveAdsUser;

//    public Text susbcriptionState;
//    private bool isSubcriptionUser;

//    // Use this for initialization
//    void Start()
//    {

//        SDKFunc.LogError("app \n aaa");

//        //GlodCount = PlayerPrefs.GetInt("KK_TEST_CONSUMER_GLOD_COUNT", 0);
//        //GlodNumber.text = GlodCount.ToString();

//        //ProductDetail product1 = new ProductDetail("com.gameinlife.ball.blast.games.gem00", ProductType.Consume);//消耗型商品
//        //ProductDetail product2 = new ProductDetail("com.gameinlife.ball.blast.games.one_time_purchase", ProductType.NonConsume);//非消耗型商品
//        //ProductDetail product3 = new ProductDetail("com.gameinlife.ball.blast.games.weekly", ProductType.Subs);//订阅商品
//        //KKPurchase.instance.Init(true, new List<ProductDetail> { product1, product2, product3 });
//        //KKPurchase.instance.onRestore += OnRestore;
//        //KKPurchase.instance.onPurchaseCallback += OnPurchaseCallBack;
//    }
//    void OnRestore(string productIdentifier)
//    {
//        if (productIdentifier.Equals("com.gameinlife.ball.blast.games.one_time_purchase"))
//        {
//            RefreshRemoveAds();
//        }
//        else if(productIdentifier.Equals("com.gameinlife.ball.blast.games.weekly"))
//        {

//            RefreshSubscriptionState();
//        }
//    }
//    void OnPurchaseCallBack(KKPurchase.PurchaseState state,string s){
//        if (state == KKPurchase.PurchaseState.PurchasedFailed)
//        {
//            SDKFunc.LogError("购买失败原因" + s);

//        } else if (state == KKPurchase.PurchaseState.PurchasedSucceed)
//        {

//            switch (s)
//            {
//                case "com.gameinlife.ball.blast.games.gem00":
//                    SDKFunc.LogError("购买成功的商品:" + s);
//                    GlodCount += 100;
//                    GlodNumber.text = GlodCount.ToString();
//                    PlayerPrefs.SetInt("KK_TEST_CONSUMER_GLOD_COUNT", GlodCount);
//                    break;
//                case "com.gameinlife.ball.blast.games.one_time_purchase":
//                    RefreshRemoveAds();
//                    break;
//                case "com.gameinlife.ball.blast.games.weekly":
//                    RefreshSubscriptionState();
//                    break;

//            }
//        }
//    }
//    private void RefreshRemoveAds()
//    {
//        isRemoveAdsUser = true;
//        removeAdsUser.text = isRemoveAdsUser.ToString();
//    }
//    private void RefreshSubscriptionState()
//    {
//        isSubcriptionUser = true;
//        susbcriptionState.text = isSubcriptionUser.ToString();
//    }
//    private void OnDestroy()
//    {
//        KKPurchase.instance.onRestore -= OnRestore;
//        KKPurchase.instance.onPurchaseCallback -= OnPurchaseCallBack;
//    }
//}
